package cc.picc;

import cc.picc.quota.QuotaBucketContainer;
import cc.picc.quota.QuotaBucketOperator;
import cc.picc.quota.StringQuotaBucket;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * 模拟令牌提供者
 * 
 * @author lijinting01
 *
 */
@AllArgsConstructor
@Slf4j
public class QuotaPublisher implements QuotaBucketOperator {

	private QuotaBucketContainer<StringQuotaBucket, String> quotaBucketContainer;

	@Override
	public void operate(String name) {
		quotaBucketContainer.get(name, (StringQuotaBucket b) -> log
				.info(String.format("尝试添加 %d个令牌   实际添加%d个  当前桶大小是%d", b.capacity(), b.fill(b.capacity()), b.size())));
	}

}
